package io.renren.modules.im.controller;


import io.renren.common.utils.R;
import io.renren.modules.im.entity.IMMessages;
import io.renren.modules.im.service.IMMessagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/im/messages")
public class IMMessagesController {

    @Autowired
    private IMMessagesService imMessagesService;

    @PostMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        long mFromUserID = Long.parseLong(params.get("mFromUserID").toString());
        long mToUserID = Long.parseLong(params.get("mToUserID").toString());
        List<IMMessages> messages = imMessagesService.listMsg(mFromUserID, mToUserID);

        return R.ok().put("data", messages);
    }

}
